package ${package};

import com.lazyframework.commons.support.PageInfo;
import com.lazyframework.commons.support.Pageable;
import com.lazyframework.commons.support.ResponseModel;
import com.lazyframework.commons.support.ResponseModels;
import com.lazyframework.commons.support.validate.VGroups;
<#assign model="${domainObj + 'Model'}">
<#assign form="${domainObj + 'Form'}">
import ${basePackage}.web.${module}.form.${form};
import ${basePackage}.model.${module}.${model};
import ${basePackage}.service.${module}.${domainObj + 'Service'};
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Api(tags = "${comment}")
@RestController
@RequestMapping("/${requestMapping}")
public class ${clsName} {

    @Autowired
    private ${domainObj + 'Service'} ${serviceName};

    @PostMapping
    @ApiOperation("新增")
    public ResponseModel<Boolean> insert(@RequestBody @Validated(VGroups.Add.class) ${form} form) {
        return ResponseModels.ok(${serviceName}.insert(form));
    }

    @DeleteMapping
    @ApiOperation("根据ID删除")
    public ResponseModel<Boolean> deleteById(@RequestParam String ids) {
        return ResponseModels.ok(${serviceName}.deleteByIds(ids));
    }

    @PutMapping
    @ApiOperation("修改")
    public ResponseModel<Boolean> update(@RequestBody @Validated(VGroups.Edit.class) ${form} form) {
        return ResponseModels.ok(${serviceName}.update(form));
    }

    @GetMapping
    @ApiOperation("根据ID查询")
    public ResponseModel<${model}> findById(@RequestParam String id) {
        return ResponseModels.ok(${serviceName}.findById(id));
    }

    @GetMapping("/list")
    @ApiOperation("查询全部")
    public ResponseModel<List<${model}>> lisAll() {
        return ResponseModels.ok(${serviceName}.listAll());
    }

    @GetMapping("/page")
    @ApiOperation("查询分页列表")
    public ResponseModel<PageInfo<${model}>> listPage(Pageable pageable) {
        return ResponseModels.ok(${serviceName}.listPage(pageable));
    }

}